package com.xz.freshmall.taomi.activity;

import android.os.Bundle;

import com.blankj.utilcode.util.SPUtils;
import com.xz.freshmall.R;
import com.xz.freshmall.taomi.dialog.PrivacyAgreementDialogFragment;

import androidx.appcompat.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        boolean aBoolean = SPUtils.getInstance().getBoolean(PrivacyAgreementDialogFragment.SP_IS_FIRST_ENTER_APP, false);
        if (!aBoolean) {
            PrivacyAgreementDialogFragment fragment = new PrivacyAgreementDialogFragment();
            fragment.setOnNextListener(() -> {
                LauncherActivity.forward(SplashActivity.this);
                finish();
            });
            fragment.show(getSupportFragmentManager(), PrivacyAgreementDialogFragment.class.getSimpleName());
        } else {
            LauncherActivity.forward(this);
            finish();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        boolean aBoolean = SPUtils.getInstance().getBoolean(PrivacyAgreementDialogFragment.SP_IS_FIRST_ENTER_APP, false);
        if (aBoolean) {
            LauncherActivity.forward(this);
            finish();
        }
    }
}
